<template>
    <view>	
        <view class="search-bar-wrap" :class="{'fixed': fixed}">
	        <view class="search-bar">
	        	<image class="search-bar-icon" src="../../static/searchIcon.png"></image>
	        	<input class="search-key-input" :placeholder="phlText" maxlength="20" placeholder-class="search-key-phcolor" confirm-type="search" @confirm="search" v-model="searchKey" />
	        </view>
	    </view>
		 <view class="search-bar-fixed-shim" v-if="fixed"></view>
	</view>	
</template>

<script>
	export default {
		name: "searchBar",
		props:{
			phlText:{
				type: String,
				default: '输入姓名、手机号搜索'
			},
			fixed:{
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
                searchKey:''
			};
		},
		methods: {
			search(){
				this.$emit('search', this.searchKey)
			},
			reset(){
				this.searchKey = ''
			}
		}
	}
</script>

<style lang="less">
	.search-bar-wrap {
		&.fixed{
		    position: fixed;
		    top: 0;
		    left: 0;
		    display: flex;
		    align-items: center;
		    background-color: #fff;
		    width: 750rpx;
		    z-index: 10;	
		}
	    .search-bar {
	    	width: 690rpx;
	    	height: 80rpx;
	    	border-radius: 40rpx;
	    	margin: 20rpx auto;
	    	display: flex;
	    	align-items: center;
	    	background-color: #F1F1F1;
	    	box-sizing: border-box;
	    	padding: 20rpx 28rpx;
	    }
	    .search-bar-icon {
	    	width: 30rpx;
	    	height: 30rpx;
	    	margin-right: 16rpx;
	    }
	    .search-key-input {
	    	flex: 1;
	    	font-size: 30rpx;
	    	font-weight: 400;
	    	color: #666;
	    	line-height: 42rpx;
	    }
	    .search-key-phcolor {
	    	color: #BFBFBF;
	    }
	}
	.search-bar-fixed-shim{
		height:  120rpx;
	}
</style>
